<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateBuildingsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('buildings', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('house_id')->comment('关联房产');
            $table->foreign('house_id')->references('id')->on('houses')->onDelete('cascade');
            $table->string('name')->comment('楼栋名称');
            $table->unsignedTinyInteger('floor')->comment('楼层');
            $table->string('description')->comment('描述')->nullable();
            $table->string('image')->comment('图片')->nullable();
            $table->boolean('is_rent')->comment('是否整栋楼出租')->default(false);
            $table->string('public_utilities')->comment('公共设施')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('buildings');
    }
}
